﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class bbs : System.Web.UI.Page
    {
        study.BLL.tb_bbs_class bll = new study.BLL.tb_bbs_class();
        study.BLL.vi_note_list vbll = new study.BLL.vi_note_list();
         
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["MENU_SELECTED"] = 1;
            if (!IsPostBack)
            {
                databond();
            }
            login_status.Visible = false;
            login.Visible = false;
            if (Session["USER"] != null)
            {
                this.login_status.Visible = true;
               // login_status.uermod = ((study.Model.tb_user)Session["USER"]).ID;
                login_status.loadover(true);
            }

            this.login.Visible = !this.login_status.Visible;
            not_title.Text = Session["CLASSNAME"].ToString();
        }

        protected void databond()
        {
            DataSet ds = new DataSet();
            StringBuilder strWhere = new StringBuilder();

            //strWhere.AppendFormat("iseable like '%{0}%'", true);

            ds = bll.GetList(strWhere.ToString());

            if (Session["CLASSNAME"] == null || Session["CLASSID"] == null)
            {
                Session["CLASSNAME"] = ds.Tables[0].Rows[0]["class_name"].ToString();
                Session["CLASSID"] = ds.Tables[0].Rows[0]["ID"].ToString();
            }

            ListView1.DataSource = ds;
            ListView1.DataBind();

        }


        protected void select_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (string.Equals(e.CommandName, "selectlist"))
            {
                LinkButton x = (LinkButton)e.CommandSource;
                
                Session["CLASSNAME"] = x.Text;
                Session["CLASSID"] = e.CommandArgument.ToString();
                not_title.Text = Session["CLASSNAME"].ToString();
               // Response.AddHeader("Refresh", "0");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["USER"] == null)
            {
                Response.Write("<script LANGUAGE='javascript'>alert('请先登录！')</script>");
                return;
            }
            Response.Redirect("Post.aspx");
        }

    }
}